<?php
class Honeymoon{

	function __construct(){
		
	}

	function __destruct(){

	}
    
	public static function getPackage($parms=null){
    		
        $qry = "select * from honeymoon_package ";
		if( $parms ){      
             $limitClaus = '';
             if( $parms['paging'] > 0 && $parms['count']<>1 ){
                $perpage = $parms['pagecount'] > 0 ? $parms['pagecount'] : 20;
                $limit =  ($parms['paging']-1)*$perpage;
                $limitClaus = " limit $limit, $perpage ";
             }              
        }
        
		//$qry = "select * from admin where username=".MyDB::$db->qstr($uname)." and password=".MyDB::$db->qstr($pass)." ";
        $qry .= $limitClaus;
		$rs = MyDB::$db->Execute($qry);
		if( $rs ){
			if( $parms['count']==1) return $rs->RecordCount();
            
            $arr = $rs->GetArray();
			return $arr;
		}
		return false;
	}             
    
    public static function getPackageType($parms=null){
            
        $qry = "select * from honeymoon_type_master ";
        if( $parms ){      
             $limitClaus = '';
             if( $parms['paging'] > 0 && $parms['count']<>1 ){
                $perpage = $parms['pagecount'] > 0 ? $parms['pagecount'] : 20;
                $limit =  ($parms['paging']-1)*$perpage;
                $limitClaus = " limit $limit, $perpage ";
             }              
        }
                
        $qry .= $limitClaus;
        $rs = MyDB::$db->Execute($qry);
        if( $rs ){
            if( $parms['count']==1) return $rs->RecordCount();
            
            $arr = $rs->GetArray();
            return $arr;
        }
        return false;
    }             
    
    public static function getPackageDestination($parms=null,$condition=null){
            
        $qry = "select * from honeymoon_package_destination ";
        if( !empty($condition) ){
            foreach( $condition as $key => $val ){
                $tmpArr[] = $key .'='. MyDB::$db->qstr($val);                
            }
            $qry = $qry . ' where '.implode(' && ', $tmpArr);
        }
        if( $parms ){      
             $limitClaus = '';
             if( $parms['paging'] > 0 && $parms['count']<>1 ){
                $perpage = $parms['pagecount'] > 0 ? $parms['pagecount'] : 20;
                $limit =  ($parms['paging']-1)*$perpage;
                $limitClaus = " limit $limit, $perpage ";
             }              
        }
                
        $qry .= $limitClaus;
        $rs = MyDB::$db->Execute($qry);
        if( $rs ){
            if( $parms['count']==1) return $rs->RecordCount();
            
            $arr = $rs->GetArray();
            return $arr;
        }
        return false;
    }             
    
    public static function getThemeById($id=null){
        if( $id>0 ){
            $qry = "select * from honeymoon_theme_master where id=".MyDB::$db->qstr($id)." and status='1'";
            $rs = MyDB::$db->Execute($qry);  
            if( $rs ){
                $arr = $rs->fetchRow();
                return $arr;                
            }
        }else{                                           
            $qry = "select * from honeymoon_theme_master where status='1'";
            $rs = MyDB::$db->Execute($qry);  
            if( $rs ){
                $arr = $rs->GetArray();
                return $arr;                
            }        
        }
        return false;     
    }
    
    public static function getPackageById($id=null, $condition=null){
        if( $id>0 ){
            $qry = "select * from honeymoon_package where id=".MyDB::$db->qstr($id);
            if( !empty($condition) ){
                foreach( $condition as $key => $val ){
                    $tmpArr[] = $key .'='. MyDB::$db->qstr($val);                
                }
                $qry = $qry . ' && '.implode(' && ', $tmpArr);
            }
            
            $rs = MyDB::$db->Execute($qry);  
            if( $rs ){
                $arr = $rs->fetchRow();
                return $arr;                
            }
        }
        return false;     
    }   
    
    
}
?>